package com.mapper.living;

import com.util.living.LivingQiNiuYunUtils;
import living.com.domain.FansUser;
import living.com.domain.User;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import org.springframework.util.Assert;

import java.util.List;

/**
 * @author 大忽悠
 * @create 2022/2/11 19:16
 */
@Repository
@RequiredArgsConstructor
public class UserDao {
    private final UserDaoBak userDaoBak;
    private final LivingQiNiuYunUtils livingQiNiuYunUtils;

    public User getUserById(int id)
    {
        User user = userDaoBak.doGetUserById(id);
        Assert.notNull(user,"用户不存在");
       user.setAvatar(livingQiNiuYunUtils.getLivingFilePrefix()+user.getAvatar());
        return user;
    }

    public User publishWithAttention(int user_id, int attention_id)
    {
        User user = userDaoBak.publishWithAttention(user_id, attention_id);
        if(user.getAvatar().contains(livingQiNiuYunUtils.getLivingFilePrefix()))
        {
            return user;
        }
        user.setAvatar(livingQiNiuYunUtils.getLivingFilePrefix()+user.getAvatar());
        return user;
    }

    public void inform(int userId, Integer objectId, String reason, String objectType) {
      userDaoBak.inform(userId,objectId,reason,objectType);
    }

}
